<template>
  <div class="im-hq-topInput" style="margin-top:5px">
    <div>
      <el-button size="mini" type="primary" @click="handleQuery">查询</el-button>
      <a @click="toggleAdvanced" href="#" style="font-size:0.8em">
        {{ advanced?"收起":"展开" }}
        <i :class="advanced?'el-icon-arrow-up':'el-icon-arrow-down'"></i>
      </a>
    </div>
    <div class="im-hq-topInputList">
      <ul>
      <li>
        <el-input
          size="mini"
          v-model="barcode"
          placeholder="请输入内容"
           
        ></el-input>
        <span>条码：</span>
      </li>
      <li>
        <el-input
          size="mini"
          v-model="itemCode"
          placeholder="请输入内容"
           
        ></el-input>
        <span>图号：</span>
      </li>
      <li>
        <el-input
          size="mini"
          v-model="mProductNumber"
          placeholder="请输入内容"
           
        ></el-input>
        <span>成品型号：</span>
      </li>
      <li>
        <el-input
          size="mini"
          v-model="qualityCode"
          placeholder="请输入内容"
           
        ></el-input>
        <span>质量编号：</span>
      </li>
      <li>
        <el-select size = "mini" v-model="deliveryStatus" placeholder="请选择状态">
          <el-option label="所有状态" value=""></el-option>
          <el-option label="未确认" value="1"></el-option>
          <el-option label="已移交" value="2"></el-option>
          <el-option label="待入库" value="3"></el-option>
          <el-option label="已入库" value="6"></el-option>
          <el-option label="已退回" value="7"></el-option>
        </el-select>
        <span>交接状态：</span>
      </li>
      <li>
        <el-input
          size="mini"
          v-model="deliveryPlanCode"
          placeholder="请输入内容"
           
        ></el-input>
        <span>交接单号：</span>
      </li>
      <li>
        <el-input
          size="mini"
          v-model="deliveryShop"
          placeholder="请输入内容"
           
        ></el-input>
        <span>移交单位：</span>
      </li>
      <li>
        <el-input
          size="mini"
          v-model="requireShop"
          placeholder="请输入内容"
           
        ></el-input>
        <span>需求单位：</span>
      </li>
      <!-- <li>
        <el-input
          size="mini"
          v-model="receiveOrgCode"
          placeholder="请输入内容"
           
        ></el-input>
        <span>接收单位简码：</span>
      </li> -->
      <li>
        <el-select size = "mini" v-model="deliveryStatu" placeholder="正常">
          <el-option label="正常" value="1"></el-option>
          <el-option label="作废" value="2"></el-option>
        </el-select>
        <span>是否正常：</span>
      </li>
      <div v-show="advanced">
        <li>
          <el-input  size="mini"  v-model="aoCode"  placeholder="请输入内容"></el-input>
          <span>AO：</span>
        </li>
        <li>
        <el-input
          size="mini"
          v-model="productCode"
          placeholder="请输入内容"
           
        ></el-input>
        <span>机型：</span>
      </li>
      <li>
        <el-input
          size="mini"
          v-model="batchNo"
          placeholder="请输入内容"
           
        ></el-input>
        <span>批次：</span>
      </li>
      <li>
        <el-input
          size="mini"
          v-model="startLotNo"
          placeholder="请输入内容"
           
        ></el-input>
        <span>起始架次：</span>
      </li>
      <li>
        <el-input
          size="mini"
          v-model="endLotNo"
          placeholder="请输入内容"
           
        ></el-input>
        <span>截止架次：</span>
      </li>
      <li>
        <el-input
          size="mini"
          v-model="wmsDeliveryPlanId"
          placeholder="请输入内容"
           
        ></el-input>
        <span>交接单ID：</span>
      </li>
      <li>
        <el-date-picker
            size="mini"
            v-model="deliveryDate"
            type="date"
            placeholder="选择日期"
            value-format="yyyy-MM-dd"
          ></el-date-picker>
        <span>日期：</span>
      </li>
    </div>
    </ul>
    </div>
  </div>
</template>
<script>
import { handoverQuerySearch } from "@/utils/api.js";
export default {
  name: "ImHqTopInput",
  data() {
    return {
      options1: [
      {
          value: "",
          label: "所有状态",
        },
        {
          value: "1",
          label: "未确认",
        },
        {
          value: "2",
          label: "已移交",
        },
        {
          value: "3",
          label: "待入库",
        },
        {
          value: "6",
          label: "已入库",
        },
        {
          value: "6",
          label: "已入库",
        },
        {
          value: "7",
          label: "已退回",
        },
      ],
      advanced:false,
      productCode:"",
      batchNo:"",
      startLotNo:"",
      endLotNo:"",
      wmsDeliveryPlanId:"",
      itemCode:"",
      qualityCode:"",
      deliveryStatus:"",
      deliveryStatu:"1",
      deliveryPlanCode:"",
      deliveryShop:"",
      requireShop:"",
      receiveOrgCode:"",
      mProductNumber:"",
      barcode:"",
      aoCode:"",
      deliveryDate:null,
      value1: "",
      pageSize:20,
      pageNumber:1,
    };
  },
  methods:{
    handleQuery(){
      handoverQuerySearch({
        searchParams: {
          productCode: this.productCode,
          batchNo: this.batchNo,
          startLotNo: this.startLotNo,
          endLotNo: this.endLotNo,
          wmsDeliveryPlanId:this.wmsDeliveryPlanId,
          itemCode: this.itemCode,
          qualityCode: this.qualityCode,
          barcode:this.barcode,
          deliveryStatus: this.deliveryStatus,
          deliveryStatu: this.deliveryStatu,
          deliveryPlanCode: this.deliveryPlanCode,
          deliveryShop: this.deliveryShop,
          requireShop: this.requireShop,
          receiveOrgCode: this.receiveOrgCode,
          mProductNumber: this.mProductNumber,
          deliveryDate:this.deliveryDate,
          aoCode:this.aoCode
        },
        pageParameter: {
          rows: this.pageSize,
          page: this.pageNumber,
        }
      }).then((res)=>{
        // 将条件查找的数据传给Table
        this.$bus.$emit("ImHqSearchData", res.data.responseBody);
        console.log("入库查询Search", res);
        if(res.data.retCode == 201) {
          this.$Alert({
            title: "失败",
            message: res.data.message,
            type: "error",
          });
        }
      })
    },
    toggleAdvanced(){
      this.advanced = !this.advanced;
    }
  },
  mounted(){
    this.$bus.$on('imHqPageSize',(e)=>{
      this.pageSize = e
      handoverQuerySearch({
        searchParams: {
          productCode: this.productCode,
          batchNo: this.batchNo,
          startLotNo: this.startLotNo,
          endLotNo: this.endLotNo,
          wmsDeliveryPlanId:this.wmsDeliveryPlanId,
          itemCode: this.itemCode,
          qualityCode: this.qualityCode,
          barcode:this.barcode,
          deliveryStatus: this.deliveryStatus,
          deliveryStatu: this.deliveryStatu,
          deliveryPlanCode: this.deliveryPlanCode,
          deliveryShop: this.deliveryShop,
          requireShop: this.requireShop,
          receiveOrgCode: this.receiveOrgCode,
          mProductNumber: this.mProductNumber,
        },
        pageParameter: {
          rows: this.pageSize,
          page: this.pageNumber,
        }
      }).then((res)=>{
        // 将条件查找的数据传给Table
        this.$bus.$emit("ImHqSearchData", res.data.responseBody);
        console.log("入库查询Search", res);
      })
    })
    this.$bus.$on('imHqPageNumber',(e)=>{
      this.pageNumber = e
      handoverQuerySearch({
        searchParams: {
          productCode: this.productCode,
          batchNo: this.batchNo,
          startLotNo: this.startLotNo,
          endLotNo: this.endLotNo,
          wmsDeliveryPlanId:this.wmsDeliveryPlanId,
          itemCode: this.itemCode,
          barcode:this.barcode,
          qualityCode: this.qualityCode,
          deliveryStatus: this.deliveryStatus,
          deliveryStatu: this.deliveryStatu,
          deliveryPlanCode: this.deliveryPlanCode,
          deliveryShop: this.deliveryShop,
          requireShop: this.requireShop,
          receiveOrgCode: this.receiveOrgCode,
          mProductNumber: this.mProductNumber,
        },
        pageParameter: {
          rows: this.pageSize,
          page: this.pageNumber,
        }
      }).then((res)=>{
        // 将条件查找的数据传给Table
        this.$bus.$emit("ImHqSearchData", res.data.responseBody);
        console.log("入库查询Search", res);
      })
    })
    // 修改刷新Table并定位页数
    this.$bus.$on('sysSlRefreshTable',(e)=>{
      this.$options.methods.handleQuery.bind(this)()
    })
  }
};
</script>
<style scoped>
.el-select {
  width: 140px;
}
.el-input {
  width: 140px;
}
.im-hq-topInput {
  overflow: hidden;
}
.im-hq-topInputList {
  text-align: center;
}
.im-hq-topInput ul li {
  float: left;
  width: 23%;
  height: 30px;
  line-height: 30px;
  margin-right: 1%;
  margin-bottom: 5px;
}
.im-hq-topInput ul li span {
  float: right;
}
.im-hq-topInput ul li div {
  float: right;
}
</style>